package cn.smile.commons.enums.wechat;

import lombok.Getter;
import org.springframework.util.ObjectUtils;

import java.util.Objects;

@Getter
public enum WeChatPublishStatusEnum {
    /**
     * 未发布
     */
    UNPUBLISH(0, "未发布"),
    /**
     * 发布中
     */
    PUBLISHING(1, "发布中"),
    /**
     * 发布成功
     */
    PUBLISH_FAILURE(2, "发布失败"),
    /**
     * 发布成功
     */
    PUBLISH_SUCCESS(3, "发布成功"),
    /**
     * 未知
     */
    NULL(-1, "未知");

    private final Integer sn;
    private final String msg;

    WeChatPublishStatusEnum(Integer sn, String msg) {
        this.sn = sn;
        this.msg = msg;
    }

    public static WeChatPublishStatusEnum get(Integer code) {
        if (!ObjectUtils.isEmpty(code)) {
            for (WeChatPublishStatusEnum status : values()) {
                if (Objects.equals(status.getSn(), code)) {
                    return status;
                }
            }
        }
        return NULL;
    }
}
